package com.dmtt.web.controller;

import com.dmtt.util.R;
import com.dmtt.web.entity.ActivationVo;
import com.dmtt.web.entity.CarStatus;
import com.dmtt.web.entity.RealTimeData;
import com.dmtt.web.entity.TotalCount;
import com.dmtt.web.service.HomePageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/web")
public class HomePageController {

    @Autowired
    private HomePageService homePageService;
    /**
     * 状态列表
     * @return
     */
    @RequestMapping("/carStatusList")
    public R carStatusList(@RequestBody ActivationVo activationVo){
        List<CarStatus> carStatusList = homePageService.carStatusList(activationVo);
        return R.ok().put("carStatusList",carStatusList);
    }

    /**
     * 状态列表导出
     * @return
     */
    @RequestMapping("/carStatusListExport")
    public ResponseEntity<byte[]> carStatusListExport(@RequestBody ActivationVo activationVo){
        return homePageService.carStatusListExport(activationVo);
    }

    //地图弹框
    @RequestMapping("/realTimeData")
    public R realTimeData(@RequestBody ActivationVo activationVo){
        List<CarStatus> realTimeData = homePageService.realTimeData(activationVo);
        return R.ok().put("realTimeData",realTimeData);
    }

    //首页总数
    @RequestMapping("/totalCount")
    public R totalCount(){
        TotalCount realTimeData = homePageService.totalCount();
        return R.ok().put("realTimeData",realTimeData);
    }
}
